events.spec.js ➔ ... ➔ before   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 9.6666
1
'use strict';
2
3
var _ = require('lodash');
4
var expect = require('chai').expect;
5
var path = require('path');
6
var sinon = require('sinon');
7
8
var projectRoot = path.resolve(__dirname, '..', '..', '..', '..');
9
10
describe('events', function () {
11
  var runtime;
12
13
  before(function () {
14
    _.set(global, 'chrome.runtime', {
15
      onMessage: {
16
        addListener: sinon.spy()
17
      }
18
    });
19
20
    runtime = global.chrome.runtime;
21
  });
22
23
  describe('initialization', function () {
24
    it('should bind to message events', function () {
25
      var initialCallCount = runtime.onMessage.addListener.callCount;
26
27
      // eslint-disable-next-line
28
      require(path.join(projectRoot, 'source', 'js', 'events'));
29
30
      expect(runtime.onMessage.addListener.callCount).to.be.greaterThan(initialCallCount);
31
    });
32
  });
33
});
34